<?php

class ClientController extends API_Controller {
    protected static $client,
                     $id;
    
    public function init(){
        parent::init();
        if(!API_Auth::isAuth())
            self::go("/");
        self::$client = API_Auth::getMyData();
        self::$id = self::$client['CLIENT_ID'];
        self::assign('client', self::$client);
        self::setTitle('Личный кабинет');
    }
 
    public function indexAction(){
        self::setTitle('Мои телефоны');
        $phones = API_Numbers::getNumbersByClient(self::$id);
        self::assign('phones', $phones);
        self::parse();
    }
    
    public function phoneAction(){
        $ph = API_Numbers::normNum(self::getPar(0));
        if(!API_Numbers::isClientsNumber(self::$id, $ph))
            self::go("/");
        self::setTitle('Статистика по номеру '.$ph);
        self::assign('phone', $ph);
        $stat = API_Numbers::getStatistic($ph);
        self::assign('stat', $stat);
        self::parse();
    }
    
    public function recacheAction(){
        API_Auth::reCache();
        self::go("/client/");
    }
}